package com.myapp.ui;

import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;

public class BaseAction extends ActionSupport implements ServletRequestAware, SessionAware ,ServletResponseAware {
	protected HttpServletRequest request;
	protected Map session;
	protected HttpServletResponse response;
	
	protected void toVm(Map<String,Object> result) {

	        ValueStack context = ActionContext.getContext().getValueStack();
	        context.set("result", result);
	        Set<String> set = result.keySet();
	        for (String key : set) {
	            context.set(key, result.get(key));
	        }
	 }
	@Override
	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		this.request=arg0;
	}

	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		this.response=arg0;
	}
	
}
